package org.qing.slice.excel.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class FileUtils {
	
	public static void copy(String src, String desc) {
		copy(new File(src), new File(desc));
	}
	
	public static void copy(File src, File desc) {
		if (src == null || !src.exists()) {
			return;
		}
		if (desc == null) {
			System.out.println("目标文件为空");
			return;
		} else {
			desc.getParentFile().mkdirs();
		}
		try (
				FileInputStream fileInputStream = new FileInputStream(src);
				FileOutputStream fileOutputStream = new FileOutputStream(desc);
			){
			byte[] b = new byte[1024 * 1024];
			int length = fileInputStream.read(b);
			while (length != -1) {
				fileOutputStream.write(b, 0, length);
				length = fileInputStream.read(b);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
